﻿// "Therefore those skilled at the unorthodox
// are infinite as heaven and earth,
// inexhaustible as the great rivers.
// When they come to an end,
// they bagin again,
// like the days and months;
// they die and are reborn,
// like the four seasons."
// 
// - Sun Tsu,
// "The Art of War"


namespace Infrastructure.Logging
{
    /// <summary>
    /// Wraps object that implements <see cref="IFixingRequired"/> interface not to expose the 
    /// <see cref="log4net.Core.IFixingRequired"/> interface outside.<br/>
    /// Objects that implement the first interface are wrapped for log4net by this object.
    /// </summary>
    internal sealed class FixingWrapper : log4net.Core.IFixingRequired
    {
        /// <summary>
        /// the real object that get the fixed value
        /// </summary>
        private readonly IFixingRequired _object;

        /// <summary>
        /// Init.
        /// </summary>
        /// <param name="obj">the object to fix</param>
        public FixingWrapper( IFixingRequired obj )
        {
            _object = obj;
        }

        /// <summary>
        /// the real object that get the fixed value
        /// </summary>
        public IFixingRequired Object
        {
            get { return _object; }
        }

        /// <summary>
        /// Get a portable version of this object
        /// </summary>
        /// <returns>the portable instance of this object</returns>
        /// <remarks>
        /// <para>
        /// Get a portable instance object that represents the current
        /// state of this object. The portable object can be stored
        /// and logged from any thread with identical results.
        /// </para>
        /// </remarks>
        public object GetFixedObject()
        {
            return _object.GetFixedObject();
        }
    }
}
